/**
 * Copyright (c) 2018 湖南牛数 All rights reserved.
 * <p>
 * https://www.dshubs.io
 * <p>
 * 版权所有，侵权必究！
 */

package io.dshubs.feign;

import io.dshubs.commons.tools.constant.ServiceConstant;
import io.dshubs.commons.tools.utils.Result;
import io.dshubs.commons.tools.validator.ValidatorUtils;
import io.dshubs.commons.tools.validator.group.DefaultGroup;
import io.dshubs.dto.SysDictDataDTO;
import io.dshubs.dto.SysDictTypeDTO;
import io.dshubs.feign.fallback.DictFeignClientFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 字典接口
 *
 * @author Mark sunlightcs@gmail.com
 */
@FeignClient(name = ServiceConstant.DSHUBS_ADMIN_SERVER, contextId = "DictFeignClient", fallbackFactory = DictFeignClientFallbackFactory.class)
public interface DictFeignClient {

    /**
     * 字典类型列表
     */
    @GetMapping("sys/dict/type/list")
    Result<List<SysDictTypeDTO>> getDictTypeList();

    @GetMapping("/sys/dict/data/type/{dictType}")
    Result<List<SysDictDataDTO>> getDictByType(@PathVariable(value = "dictType", required = false) String dictType);

    /**
     * 保存
     */
    @PostMapping("sys/dict/type")
    Result<List<SysDictTypeDTO>> save(@RequestBody SysDictTypeDTO dto);

    /**
     * 保存
     * @param dto dto
     * @return Result
     */
    @PostMapping("sys/dict/data")
    Result saveData(@RequestBody SysDictDataDTO dto);


    @GetMapping("sys/dict/type/list/code")
    @ApiOperation("字典类型")
    Result<List<SysDictDataDTO>> listByCode(@RequestBody Long code);

    @GetMapping("sys/dict/data/{id}")
    Result<SysDictDataDTO> get(@PathVariable(value = "id") Long id);
}